<div class="layui-card">
    <div class="layui-card-header">
        <span class="layui-breadcrumb pull-right">
            <a href="#!console">首页</a>
            <a><cite>玩家基础信息</cite></a>
        </span>
    </div>

    <div class="layui-form" method="get">
        <div class="layui-form-item">
            搜索：
            <!--<label class="layui-form-label">搜索：</label>-->
            <div id="player-search-key"></div>
            <input id="player-search-value" class="layui-input search-input" placeholder="输入关键字">
            <button id="player-btn-search" class="layui-btn icon-btn"><i class="layui-icon">&#xe615;</i>搜索</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>

    <div class="layui-card-body">
        <div class="layui-form toolbar nowrap">
            <table class="layui-table" id="player-table" lay-filter="player-table"></table>
        </div>
    </div>
</div>
<script type="text/javascript" src="../../module/id.js"></script>
<script>
    var bsdldData = [
        {
            "id": "playerId"
            , "name": "玩家ID"
        }, {
            "id": "phone"
            , "name": "手机号"
        }, {
            "id": "nickName"
            , "name": "昵称"
        }, {
            "id": "type"
            , "name": "玩家类型"
            , "children": [{
                "id": 1
                , "name": "游客"
            }, {
                "id": 0
                , "name": "手机"
            }]
        }, {
            "id": "online"
            , "name": "是否在线"
            , "children": [{
                "id": 1
                , "name": "在线"
            }, {
                "id": 0
                , "name": "不在"
            }]
        },
    ];
    var key1;
    var value_type;

    layui.extend({
        selectN: '../../module/layuiSelect/selectN'
        , selectM: './../../module/layuiSelect/selectM'
    }).use(['form', 'table', 'util', 'config', 'admin', 'laydate', 'layer', 'selectN', 'selectM','element'], function () {
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var layer = layui.layer;
        var util = layui.util;
        var admin = layui.admin;
        var laydate = layui.laydate;
        var layer = layui.layer;
        var selectN = layui.selectN;
        var selectM = layui.selectM;
        var element = layui.element;

        // 渲染表格
        table.render({
            elem: '#player-table',
            url: config.base_server + 'api-select/playerBaseInfo',
            method: 'GET',
            where: {
                access_token: config.getToken().access_token
            },
            page: true,
            cols: [[
                { field: 'playerId', minWidth: 110, sort: true, title: '玩家ID', unresize: true },
                { field: 'nickName',minWidth: 200, sort: false, title: '昵称' },
                { field: 'phone', minWidth: 110, sort: false, title: '手机号' },
                { field: 'type',minWidth: 60, sort: true, title: '玩家类型',templet:function(d){return d.type == 1 ? "游客" : "正常"} },
                { field: 'type',minWidth: 60, sort: true, title: '是否在线',templet:function(d){return (d.loginOn > d.logoutOn || d.logoutOn == '' || d.logoutOn == null) ? "在线" : "离线"} },
                {align: 'center',fixed: 'right', toolbar: '#player-table-bar', title: '操作',width: 100}
            ]]
        });

        <!--搜索-->
        $('#player-btn-search').click(function () {
            var value = $('#player-search-value').val();
            var key = key1;
            if (key == "type" || key == "online") {
                value = value_type;
            }
            table.reload('player-table', { where: { playerKey: key, playerValue: value } });
        });

        var catIns1 = selectN({
            //元素容器【必填】
            elem: '#player-search-key'
            , search: [false, true]
            //候选数据【必填】
            , data: bsdldData
        });

        form.on('select', function (data) {
            if (data.value == "type" || data.value == "online") {
                $("#player-search-value").hide();
            }
            if (data.value == "playerId" || data.value == "nickName" || data.value == "phone") {
                $("#player-search-value").show();
            }
            if (data.value == 0 || data.value == 1) {
                value_type = data.value;
            } else {
                key1 = data.value;
            }
        });

        table.on('tool(player-table)', function (obj) {
            var data = obj.data;
            <!--删除指定选项卡-->
            element.tabDelete('admin-pagetabs', 'playerDetails');
            setId(data.playerId);
        });
    });

</script>
<script type="text/html" id="player-table-bar">
    <a class="layui-btn layui-btn-xs" lay-event="edit" href="#!playerDetails">查看详情</a>
    <!--<a class="layui-btn layui-btn-xs" lay-event="edit">查看详情</a>-->
</script>